/**
 * Creat with IntelliJ IDEA
 * Description
 * User: mamba24
 * Date: 2022-08-12
 * Time: 11:49
 * To BE A Better Person-2020-3-2
 */
public class TestDemo6 {
    public static  long count=0;
    public static  Object locker=new Object();
    public static void main(String[] args) throws InterruptedException {

        Thread t1=new Thread(()->{
            synchronized (locker){
                for (int i = 0; i < 1000000; i++) {
                    count++;
                }
            }

        });
        Thread t2=new Thread(()->{
            synchronized (locker){
                for (int i = 0; i < 1000000; i++) {
                    count++;
                }
            }
        });
        t1.start();
        t2.start();
        t1.join();
        t2.join();
        System.out.println(count);

    }
}
